<#assign pageName="流程部署管理">
<@override name="page-content">
<form class="form-horizontal" role="form" method="post" id="formLogMgr">
     <div class="layui-form-search panel">
         <input type="text" hidden="hidden" name="_STATE"/>
         <div class="pull-left padding-5">
              <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm js_upload">
                <i class="layui-icon layui-icon-upload"></i>上传流程模型
              </a>
          </div>
     </div>
    <table class="layui-table">
        <thead>
            <tr>
                <th class="align-center" width="50px" nowrap="nowrap">序号</th>
                <th class="align-center" nowrap="nowrap">部署ID</th>
                <th class="align-center" nowrap="nowrap">流程定义ID</th>
                <th class="align-center" nowrap="nowrap">流程名称</th>
                <th class="align-center" nowrap="nowrap">版本号</th>
                <th class="align-center layui-hide-xs" nowrap="nowrap">XML</th>
                <th class="align-center" nowrap="nowrap">图片</th>
                <th class="align-center layui-hide-xs" nowrap="nowrap">部署时间</th>
                <th class="align-center" nowrap="nowrap">部署状态</th>
                <th class="align-center" nowrap="nowrap" width="120px">操作</th>
            </tr>
        </thead>

        <tbody>
        <#if (queryResult.rows)?has_content>
            <#list queryResult.rows as dataItem>
            <tr>
                <td class="align-center" width="50px" nowrap="nowrap">
                    ${(pageNo-1)*pageSize+dataItem_index+1}
                </td>
                <td class="align-center" nowrap="nowrap">
                    ${dataItem[0].deploymentId}
                </td>
                <td class="align-center" nowrap="nowrap">
                    ${dataItem[0].id}
                </td>
                <td class="align-center" nowrap="nowrap">
                    ${dataItem[0].name}
                </td>
                <td class="align-center" nowrap="nowrap">
                    ${dataItem[0].version}
                </td>
                <td class="layui-hide-xs" nowrap="nowrap">
                    <a target="_blank" href='${contextPath}/workflow/resource/read?processDefinitionId=${dataItem[0].id}&resourceType=xml'>
                        ${dataItem[0].resourceName}
                    </a>
                </td>
                <td>
                    <a target="_blank" href='${contextPath}/workflow/resource/read?processDefinitionId=${dataItem[0].id}&resourceType=image'>
                        ${dataItem[0].diagramResourceName }
                    </a>
                </td>
                <td class="align-center layui-hide-xs" nowrap="nowrap">
                    ${dataItem[1].deploymentTime?string('yyyy-MM-dd HH:mm:ss')}
                </td>
                <td class="align-center" nowrap="nowrap">
                    <#if dataItem[0].suspensionState == '2' >
                        <label class="layui-bg-red status-show">挂起</label>
                    <#else>
                        <label class="layui-bg-green status-show">激活</label>
                    </#if>
                </td>
                <td class="align-center">
                    <div class="layui-table-cell">
                         <button type="button" class="layui-btn layui-btn-warm layui-btn-xs"
                            onclick="confirmSubmit('确定要将流程‘${dataItem[0].deploymentId}’转为Model吗？', {processDefinitionId:'${dataItem[0].id}'},'converttomodel')">
                            <i class="layui-icon layui-icon-transfer"></i>转为Model
                        </button>
                        <#if dataItem[0].suspensionState == '2' >
                        <button type="button" class="layui-btn layui-btn-danger layui-btn-xs"
                            onclick="confirmSubmit('确定要激活流程‘${dataItem[0].deploymentId}’吗？', {processDefinitionId:'${dataItem[0].id}', state:'active'},'processdefinition/update')">
                            <i class="layui-icon layui-icon-delete"></i>激活
                        </button>
                        <#else>
                        <button type="button" class="layui-btn layui-btn-danger layui-btn-xs"
                            onclick="confirmSubmit('确定要挂起流程‘${dataItem[0].deploymentId}’吗？', {processDefinitionId:'${dataItem[0].id}',state:'suspend'},'processdefinition/update')">
                            <i class="layui-icon layui-icon-delete"></i>挂起
                        </button>
                        </#if>
                        <button type="button" class="layui-btn layui-btn-danger layui-btn-xs"
                            onclick="confirmSubmit('确定要删除流程‘${dataItem[0].deploymentId}’吗？所有相关的业务流程数据也将一起删除！', {deploymentId:'${dataItem[0].deploymentId}'},'del')">
                            <i class="layui-icon layui-icon-delete"></i>删除
                        </button>
                     </div>
                </td>
            </tr>
            </#list>
        <#else>
            <tr class="align-center">
                <td style="color:red;font-weight:bold;" colspan="11">暂无符合条件的流程信息</td>
            </tr>
        </#if>
        </tbody>
    </table>
    <@ctrl.pageShow (queryResult.total)!0, (queryResult.pageIndex)!0 />
</form>
</@override>
<@override name="page-scripts">
    <script>
        $(function(){
            layui.use(['form','layer','jquery'], function(){
                var form = layui.form;
                var layer=layui.layer;
                $=layui.jquery;
                $('.js_upload').on('click', function(){
                    layer.open({
                        type: 2,
                        title:'上传流程模型',
                        area: ['460px', '380px'],
                        anim: 2,
                        maxmin: false,
                        closeBtn: 1,
                        shadeClose: true,
                        shade: 0.6,
                        content: '${contextPath}/workflow/deploy/upload'
                     })
                })
            });
        })
    </script>
</@override>
<@extends name="/layout/basepage.html"/> 
